package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.RefillCard;
import com.lrkj.payfee.service.IRefillCardService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 充值卡Controller
 *
 * @author yajun_ren
 * @date 2021-07-27
 */
@RestController
@RequestMapping("/payfee/card")
public class RefillCardController extends BaseController
{
    @Autowired
    private IRefillCardService refillCardService;

    /**
     * 查询充值卡列表
     */
    @ApiOperation(value = "查询充值卡列表", notes = "查询充值卡列表")
    @GetMapping("/list")
    public TableDataInfo list(RefillCard refillCard)
    {
        startPage();
        List<RefillCard> list = refillCardService.selectRefillCardList(refillCard);
        return getDataTable(list);
    }

    /**
     * 导出充值卡列表
     */
	@ApiOperation(value = "导出充值卡列表", notes = "导出充值卡列表")
    @PreAuthorize("@ss.hasPermi('payfee:card:export')")
    @Log(title = "充值卡", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RefillCard refillCard)
    {
        List<RefillCard> list = refillCardService.selectRefillCardList(refillCard);
        ExcelUtil<RefillCard> util = new ExcelUtil<RefillCard>(RefillCard.class);
        return util.exportExcel(list, "充值卡数据");
    }

    /**
     * 获取充值卡详细信息
     */
	@ApiOperation(value = "获取充值卡详细信息", notes = "获取充值卡详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:card:query')")
    @GetMapping(value = "/{cardId}")
    public AjaxResult getInfo(@PathVariable("cardId") String cardId)
    {
        return AjaxResult.success(refillCardService.selectRefillCardById(cardId));
    }

    /**
     * 新增充值卡
     */
	  @ApiOperation(value = "新增充值卡", notes = "新增充值卡")
    @PreAuthorize("@ss.hasPermi('payfee:card:add')")
    @Log(title = "充值卡", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RefillCard refillCard)
    {
        return toAjax(refillCardService.insertRefillCard(refillCard));
    }

    /**
     * 修改充值卡
     */
	 @ApiOperation(value = "修改充值卡", notes = "修改充值卡")
    @PreAuthorize("@ss.hasPermi('payfee:card:edit')")
    @Log(title = "充值卡", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RefillCard refillCard)
    {
        return toAjax(refillCardService.updateRefillCard(refillCard));
    }

    /**
     * 删除充值卡
     */
	 @ApiOperation(value = "删除充值卡", notes = "删除充值卡")
    @PreAuthorize("@ss.hasPermi('payfee:card:remove')")
    @Log(title = "充值卡", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cardIds}")
    public AjaxResult remove(@PathVariable String[] cardIds)
    {
        return toAjax(refillCardService.deleteRefillCardByIds(cardIds));
    }
}
